<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------
namespace app\erp\behavior\coupon_receive_before;

/**
 * 是否满足领取条件
 * @package app\user_center\behavior\user
 * @author shiqiang
 */
class isGetReceive{
    /**
     * 执行行为 run方法是Behavior唯一的接口
     * @access public
     * @return void
     */
    public function run($params){
    	$user_id   			= $params['user_id'];
    	$coupon_id 			= $params['coupon_id'];
    	$coupon_get_type 	= $params['coupon_get_type'];
		
		$coupon_rules_info = model('erp/ErpCouponRules', 'model') -> where('coupon_id', $coupon_id) -> find();//规则信息
		if(empty($coupon_rules_info)){
			return array_out(-1002, '已失效，无法领取');
		}
		if(!empty($coupon_rules_info) && $coupon_rules_info['coupon_rule'] != $coupon_get_type){
			return array_out(-1002, '未满足领取条件');
		}
    }
}
